<?php defined('SYSPATH') or die('No direct script access.');

/**
 * 扫码付款应用
 */
class Controller_Pc_Api_V2_Payqrcode extends Controller_Pc_Api_V2_Base
{

    // 数据请求结果
    private $result;

    /**
     * 参数验证对象
     * @var Request_Api_V2_Payqrcode
     */
    private $validation;

    /**
     * 租车服务
     * @var Service_Api_Payqrcode
     */
    private $service = null;


    public function before()
    {
        parent::before();
        $this->result = array(
            'status' => true,
            'msg' => '操作成功',
            'data' => array()
        );
        $this->validation = Request_Api_V2_Factory::create('payqrcode', $this->request_params);
        $this->service = new Service_Api_Payqrcode();
    }
    public function after()
    {
        $this->send_datagrams($this->client_info['id'], $this->result, $this->client_info['secret_key']);
    }



    // 获取支付方式
    public function action_get_payqrcode_info()
    {
        try {
            $this->validation->get_payqrcode_info()->check();
            $data = $this->service->get_payqrcode_info($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    // 获取支付方式
    public function action_create_order()
    {
        try {
            $this->validation->create_order()->check();
            if ($this->member_info) {
                $this->request_params['member_info'] = $this->member_info;
            }
            $data = $this->service->create_order($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }






}